  function plotnorm_loop(x,tstr,m,n,fsize,opath,fname);
% function plotnorm_loop(x,tstr,m,n,fsize,opath,fname);
%
% Individual Normal Plot for the 
% columns of the matrix x
% in subplots of 
% dimension m x n 
%
% save as plot_loop but for normal plots 
% 
% Inputs 
% x     series in columns
% tstr  (optional) string for each plot 
%       default is fig. Subplots will be numbered
% m,n   row and column dimension suplots 
%       If m*n is not equal to the columns of x 
%       then first try 2 coluns of plots 
%       then move to 3 rows of plots 
% fsize (optinal) font-size for titles 
%       default if 8 
% opath (optional) output path 
% fname (optional) file name to save graph 
%       need call both last inputs to save the graph 
%
% Alejandro Justiniano @2004 
[t,c]=size(x);
if nargin < 7; 
    flagsave=0;
else 
    if isstr(fname) == 0 
        error('Need provide graph name')
    end
    flagsave=1; 
end; 

if nargin < 5 
    fsize=8; 
else 
    if fsize < 0 | fsize > 100 
        error('Excessive font size') 
    end
end
if nargin < 4 | c~=m*n
    disp('Adjusting dimension of plots'); 
    n2=c/2; 
    if n2-round(n2) == 0 
        m=n2; n=2; 
    else 
        n3=c/3; 
        m=3; 
        n=ceil(n3);     
    end  
end
if nargin < 2 | isempty(tstr)== 1
    tstr='Normp'; 
end
set(0,'DefaultAxesFontSize',7);
figure; 

ii=1; 
for ii=1:c; 
    subplot(m,n,ii); 
    normplot( x(:,ii) );
    ha=gca(gcf); 
    set(ha,'FontSize',7);
    title([tstr,' ',num2str(ii)],'FontSize',fsize); 
    
end; 
if flagsave==1 
    cucd=cd; 
    cd(opath); 
    saveas(gcf,fname,'fig'); 
    disp(['Saved graph in ',opath,' with name ',fname]); 
    cd(cucd); 
end 
set(0,'DefaultAxesFontSize','remove');